package com.koron.order.inspect.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.inspect.bean.po.OrderInspectionPo;
import com.koron.order.inspect.bean.query.OrderInspectionQuery;
import com.koron.order.inspect.service.OrderInspectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工单抽查意见表(OrderInspection)表控制层
 *
 * @author zhouj
 * @since 2022-01-14 10:16:21
 */
@Api(tags = "工单抽查意见表(OrderInspection)")
@RestController
@RequestMapping("/orderInspection/")
public class OrderInspectionController {

    @Autowired
    private OrderInspectionService orderInspectionService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改工单抽查意见表")
    @PostMapping("insertOrUpdate")
    public Response<OrderInspectionPo> insertOrUpdate(@RequestBody OrderInspectionPo orderInspection) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "insertOrUpdate", OrderInspectionPo.class, orderInspection));
    }

    @ApiOperation(value = "新增工单抽查意见表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody OrderInspectionPo orderInspection) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "insert", Integer.class, orderInspection));
    }

    @ApiOperation(value = "批量新增工单抽查意见表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<OrderInspectionPo> orderInspectionList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "insertBatch", Integer.class, orderInspectionList));
    }

    @ApiOperation(value = "根据id更新工单抽查意见表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody OrderInspectionPo orderInspection) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "update", Integer.class, orderInspection));
    }

    @ApiOperation(value = "根据id删除工单抽查意见表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询工单抽查意见表")
    @GetMapping("queryById")
    public Response<OrderInspectionPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "queryById", OrderInspectionPo.class, id));
    }

    @ApiOperation(value = "不分页查询工单抽查意见历史")
    @GetMapping("queryList")
    public Response<List> queryList(OrderInspectionPo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询工单抽查意见历史")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(OrderInspectionPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

    @ApiOperation(value = "分页查询工单抽查意见列表")
    @GetMapping("queryInspectPageList")
    public Response<PageInfo> queryInspectPageList(OrderInspectionQuery inspectionQuery, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderInspectionService, "queryInspectPageList", PageInfo.class, inspectionQuery, pageQuery));
    }

}
